/**
 * 通过 > npm run build 调用自动配置
 * wx    ： api 地址
 * wxurl ： 微信授权地址
 */

/**
 * 调试环境
 *  > npm start 会自动配置
 * @type {{wx: string, wxurl: string}}
 */
const local = {
  wx: './wx',
  login:'./login',
  main:'./main',
  appConfig: {
    endpoint: 'end_AbgxY5SbUfsJ',
    qic: 'dsy_BhyLDx9ZcQCs',
    appKey: 'dsy_BhyLDx9ZcQCs'
  }
}

/**
 * 开发环境
 * > npm run build
 * > dev
 * @type {{wx: string, wxurl: string}}
 */
const dev = {
  login:'./login',
  main:'./main',
  appConfig: {
    endpoint: 'end_AbgxY5SbUfsJ',
    qic: 'dsy_BhyLDx9ZcQCs',
    appKey: 'dsy_BhyLDx9ZcQCs'
  }
}

/**
 * 测试环境
 * > npm run build
 * > test
 * @type {{wx: string, wxurl: string}}
 */
const test = {
  login:'./login',
  main:'./main',
  appConfig: {
    endpoint: 'end_AbgxY5SbUfsJ',
    qic: 'dsy_BhyLDx9ZcQCs',
    appKey: 'dsy_BhyLDx9ZcQCs'
  }
}

/**
 * 生产环境ticket
 * > npm run build
 * > pro
 * @type {{wx: string, wxurl: string}}
 */
const proUrl = {
  login:'https://auth.gcongo.com',
  main:'https://ncov2019-api.gcongo.com/main',
  appConfig: {
    endpoint: 'end_aaBKNHOHqhFZ',
    qic: 'dsy_GaSlyLbTGWLi',
    appKey: 'dsy_GaSlyLbTGWLi'
  }
}

const localApi = {
  wxApi:'',
  mainApi:''
}

const proApi = {
  wxApi:'/appointment/api-wechat',
  mainApi:'/appointment/api-app'
}

let main = local;
let api = localApi
if(process.env.LW_ENV == 'dev'){
  main = dev;
  api = proApi;
}else if(process.env.LW_ENV == 'test'){
  main = test;
  api = proApi;
}else if(process.env.LW_ENV == 'pro'){
  main = proUrl;
  api = proApi;
}

export default {
  appConfig: main.appConfig,
  /**
   * 账号相关
   */ 

  getCode :`${main.login}/getCode`,

  wxLogin:`${main.login}/wx/login`,

  mLogin:`${main.login}/m/login`,

  hvcode :`${main.login}/mobile/hvcode`,

  // 获取微信授权中心参数appid等（因为开发时有三个接口，所以需要判断一下）
  getWxCodeUrl :`${main.wx? main.wx : main.main}${api.wxApi}/auth/getWxCodeUrl`,

  // 获取openId
  getOpenId :`${main.wx? main.wx : main.main}${api.wxApi}/auth/code`,

  // 获取微信jssdk授权
  config:`${main.wx? main.wx : main.main}${api.wxApi}/auth/config`,

  /**
   * 业务相关
   */
  // 验证ticket
  ticket:`${main.main}${api.mainApi}/ticket/verify`,

  orderConfig :`${main.main}${api.mainApi}/order/config`,

  checkTime :`${main.main}${api.mainApi}/order/checkTime`,

  getAppointmentBeforeInfo: `${main.main}${api.mainApi}/order/getAppointmentBeforeInfo`,

  list: `${main.main}${api.mainApi}/order/list`,

  order: `${main.main}${api.mainApi}/order/save`,

  // 查询预约数量是否达到
  maxPurchaseLimit: `${main.main}${api.mainApi}/order/maxPurchaseLimit`,

  // 获取预约详情
  getDetail: `${main.main}${api.mainApi}/order/getDetail`,

  // 获取预约历史
  detailList:  `${main.main}${api.mainApi}/order/detailList`,
}